local rolely_jipin = fk.CreateSkill {
  name = "rolely_jipin",

}
Fk:loadTranslationTable {
  ["rolely_jipin"] = "济贫",
  [":rolely_jipin"] = "准备阶段，你展示牌堆顶与存活人数等量的牌，所有角色依次可以选择获得一张，每有角色因此获得牌，你摸牌阶段的额定摸牌数便+1。",

  ["#rolely_jipin-ask"] = "济贫：是否展示牌堆顶的 %arg 张牌令所有角色依次选择获得？",

   ["$rolely_jipin1"] = "天书既出，太平可期！",
    ["$rolely_jipin2"] = "太平道法，天书详记！",
}
rolely_jipin:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(rolely_jipin.name) and player.phase == Player.Start
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player,
      { skill_name = rolely_jipin.name, prompt = "#rolely_jipin-ask:::" .. #player.room.alive_players })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getNCards(#room.alive_players)
    room:turnOverCardsFromDrawPile(player, cards, rolely_jipin.name) --将卡牌移动到处理区
    for _, to in ipairs(room:getAlivePlayers()) do
      cards = table.filter(cards, function(id) return room:getCardArea(id) == Card.Processing end)
      if #cards == 0 then break end
      if not to.dead then
        local chosen = room:askToChooseCards(to, {
          target = to,
          min = 0,
          max = 1,
          flag = { card_data = { { rolely_jipin.name, cards } } },
          skill_name = rolely_jipin.name,
          prompt = "济贫：是否获得其中一张？",
        })[1]
        if chosen then
          table.removeOne(cards, chosen)
          room:addPlayerMark(player, "rolely_jipin-turn")
          room:moveCardTo(chosen, Card.PlayerHand, to, fk.ReasonJustMove, rolely_jipin.name, nil, true, to)
        end
      end
    end
    room:cleanProcessingArea(cards) --清理处理区的卡牌
  end,
})

rolely_jipin:addEffect(fk.DrawNCards, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark("rolely_jipin-turn") > 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.n = data.n + player:getMark("rolely_jipin-turn")
  end,
})
return rolely_jipin
